package com.codegenerate.demo.entity; /**
========= entity ==========
*/

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.util.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;


@TableName(value ="sys_role")
public class SysRole implements Serializable {
  @TableId(value = "id", type = IdType.AUTO)
  private long id;

    @TableField(exist = false)
    private List<AppFun> appFunList;

    public List<AppFun> getAppFunList() {
        return appFunList;
    }

    public void setAppFunList(List<AppFun> appFunList) {
        this.appFunList = appFunList;
    }

    /**
            * 软删除
            * string
            */
            @TableField(value = "del_state")
            private long delState;
        

   
        
            /**
            * 权限逗号隔开
            * string
            */
            @TableField(value = "permit_ids")
            private String permitIds;
        

   
        
            /**
            * 角色
            * string
            */
            @TableField(value = "name")
            private String name;
        

   




        /**
        * region  set and get
        * */
    
           public long getId() {
             return id;
          }
          public void setId(long id) {
                 this.id = id;
          }   
   
           public long getDelState() {
             return delState;
          }
          public void setDelState(long delState) {
                 this.delState = delState;
          }   
   
           public String getPermitIds() {
             return permitIds;
          }
          public void setPermitIds(String permitIds) {
                 this.permitIds = permitIds;
          }   
   
           public String getName() {
             return name;
          }
          public void setName(String name) {
                 this.name = name;
          }   
   
        /**
        * endgion  set and get
        * */

 

    /**
        * build
        */
       public static SysRole build(){
            SysRole tempEntity = new SysRole();
            return tempEntity;
    }

    /**
        * build
        */
       public  static void setDefaultValue(SysRole temp){
              
                    if(temp.getId()<=0){
                                temp.setId(0L);
                    }        
            
                    if(temp.getDelState()<=0){
                                temp.setDelState(1);
                    }        
            
                    if(StringUtils.isEmpty(temp.getPermitIds())){
                                temp.setPermitIds("");
                    }        
            
                    if(StringUtils.isEmpty(temp.getName())){
                                temp.setName("");
                    }        
            


    }

    @JsonIgnore
    public LambdaQueryWrapper<SysRole> getQueryAll() {
                 var  query = new QueryWrapper<SysRole>().lambda();
        
                    if(this.id>0){
                                query.eq(SysRole::getId, this.id);
                    }        
            
                    if(this.delState>0){
                                query.eq(SysRole::getDelState, this.delState);
                    }        
            
                    if(!StringUtils.isEmpty(this.permitIds)){
                                query.eq(SysRole::getPermitIds, this.permitIds);
                    }        
            
                    if(!StringUtils.isEmpty(this.name)){
                                query.eq(SysRole::getName, this.name);
                    }        
            

           
            return  query;

    }

     @JsonIgnore
      public static LambdaQueryWrapper<SysRole> getQuery(){
        var query = new QueryWrapper<SysRole>().lambda();
        return query;
    }


  @JsonIgnore
     public LambdaUpdateWrapper<SysRole> getUpdateWrapper() {
        var  updateWrapper = new UpdateWrapper<SysRole>().lambda();
        
             if(this.id>0){ 
              
                     updateWrapper.eq(SysRole::getId, this.id);
              
                    }        
          
             if(!StringUtils.isEmpty(this.delState)){ 
              
                         updateWrapper.set(SysRole::getDelState, this.delState);
              
                    }        
          
             if(!StringUtils.isEmpty(this.permitIds)){ 
              
                         updateWrapper.set(SysRole::getPermitIds, this.permitIds);
              
                    }        
          
             if(!StringUtils.isEmpty(this.name)){ 
              
                         updateWrapper.set(SysRole::getName, this.name);
              
                    }        
          


        return updateWrapper;
    }

}